<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 第一种写法,两个函数金额为必须加分号;
        (function (x, y) {
            console.log(x * y);
            // let num = 23
        })(3, 9);
        (function () {
            // let num = 22
            console.log('hello world');
        })();

        // 第二种写法
        (function (x, y) {
            console.log(x + y);
        }(1, 2));


        // 小结 两种写法都可以
        (function () { })();
        (function () { }());
    </script>
</body>

</html>